package com.situ.mall.controller;

import com.situ.mall.entity.User;
import com.situ.mall.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        System.out.println("UserController.hello");
        return "hello";
    }

    @RequestMapping("/selectAll")
    @ResponseBody
    public List<User> selectAll() {
        System.out.println("UserController.selectAll");
        List<User> list = userService.selectAll();
        return list;
    }

    @RequestMapping("/getUserListPage")
    public String  getUserListPage(Model model) {
        System.out.println("UserController.getUserListPage");
        List<User> list = userService.selectAll();
        model.addAttribute("list", list);
        return "user_list";
    }

//    @RequestMapping("/login.action")
    @RequestMapping("/login")
    @ResponseBody
    public String login() {
        System.out.println("UserController.login");
        return  "login";
    }
}
